package com.xiyu.service.controller.admin.elder;
import com.xiyu.service.vo.elder.accident.AccidentGetOutput;
import com.xiyu.service.vo.elder.accident.AccidentUpdateInput;
import com.xiyu.service.vo.elder.accident.AccidentCreateInput;
import com.xiyu.service.vo.elder.accident.AccidentPageQueryOutput;
import com.xiyu.service.vo.elder.accident.AccidentPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.elder.AccidentService;

@Tag(name = "事故登记")
@RestController
@RequestMapping("/elder/accident")
@Validated
public class AccidentController {

    @Resource
    private AccidentService accidentService;

    @PostMapping("/page-query")
    @Operation(summary = "分页查询事故登记")
    @PreAuthorize("@ss.hasPermission('elder:accident:query')")
    public CommonResult<PageResult<AccidentPageQueryOutput>> pageQuery(@Valid @RequestBody AccidentPageQueryInput inputVO) {
        return success(accidentService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增事故登记")
    @PreAuthorize("@ss.hasPermission('elder:accident:create')")
    public CommonResult<Long> create(@Valid @RequestBody AccidentCreateInput inputVO) {
        return success(accidentService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新事故登记")
    @PreAuthorize("@ss.hasPermission('elder:accident:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody AccidentUpdateInput inputVO) {
        return success(accidentService.update(inputVO));
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个事故登记")
    @Parameter(name = "id", description = "事故登记主键ID", example = "")
    public CommonResult<AccidentGetOutput> get(@RequestParam("id") Long id) {
        return success(accidentService.get(id));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除事故登记")
    @PreAuthorize("@ss.hasPermission('elder:accident:delete')")
    @Parameter(name = "id", description = "事故登记主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(accidentService.deleted(id));
    }

}
